﻿using UnityEngine;
using System.Collections;

public class SingleInstance<T> where T : new()
{
    public static T m_instance;
    private static object m_lockObj = new object();
    public static T GetInstance()
    {
        lock (m_lockObj)
        {
            if (m_instance == null)
            {
                m_instance = new T();
            }
        }
        return m_instance;
    }

    public static T instance
    {
        get
        {
            return GetInstance();
        }
    }

    public static void Release()
    {
        m_instance = default(T);
    }

}
